# 处理不同状态码的响应
import requests

def handle_status_code(code):
    url = f"https://httpbin.org/status/{code}"
    response = requests.get(url)

    if response.status_code == 200:
        print(f"Success! Status code: {response.status_code}")
    elif response.status_code == 404:
        print(f"Not Found! Status code: {response.status_code}")
    elif response.status_code == 500:
        print(f"Server Error! Status code: {response.status_code}")
    else:
        print(f"Received status code: {response.status_code}")

# 测试多个状态码
for code in [200, 404, 500, 403]:
    handle_status_code(code)
